<!DOCTYPE html>
<html>
<head>
    <title>BootstrapValidator demo</title>

    <link rel="stylesheet" href="vendor/bootstrap/css/bootstrap.css"/>

    <script type="text/javascript" src="vendor/jquery/jquery.min.js"></script>
    <script type="text/javascript" src="vendor/bootstrap/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="dist/js/bootstrapValidator.js"></script>
</head>
<body>
        <button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">
                开始演示模态框
            </button>
            <!-- 模态框（Modal） -->
            <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                                &times;
                            </button>
                            <h4 class="modal-title" id="myModalLabel">
                                模态框（Modal）标题
                            </h4>
                        </div>
                        <div class="modal-body">
                                <form id="defaultForm" method="post" action="target.php" class="form-horizontal">
                    
             
                                    <div class="form-group">
                                        <label class="col-lg-3 control-label">原始密码</label>
                                        <div class="col-lg-5">
                                            <input type="text" class="form-control" name="username" />
                                        </div>
                                    </div>
            
                                        <div class="form-group">
                                            <label class="col-lg-3 control-label">密码</label>
                                            <div class="col-lg-5">
                                                <input type="password" class="form-control" name="password" />
                                            </div>
                                        </div>
            
                                        <div class="form-group">
                                            <label class="col-lg-3 control-label">验证密码</label>
                                            <div class="col-lg-5">
                                                <input type="password" class="form-control" name="confirmPassword" />
                                            </div>
                                        </div>
                                  
            
                                
            
                                    <div class="form-group">
                                        <div class="col-lg-9 col-lg-offset-3">
                                            <button type="submit" class="btn btn-primary">提交</button>
                                        </div>
                                    </div>
                                </form>
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-default" data-dismiss="modal">关闭
                            </button>
                            <button type="button" class="btn btn-primary">
                                提交更改
                            </button>
                        </div>
                    </div><!-- /.modal-content -->
                </div><!-- /.modal -->
            </div>








    <div class="container">
        <div class="row">
            <!-- form: -->
            <section>
                <div class="page-header">
                    <h1>Bootstrap验证插件</h1>
                </div>

                <div class="col-lg-8 col-lg-offset-2">
                    <form id="defaultForm" method="post" action="target.php" class="form-horizontal">
                    
             
                            <legend>相同的验证者</legend>

                            <div class="form-group">
                                <label class="col-lg-3 control-label">密码</label>
                                <div class="col-lg-5">
                                    <input type="password" class="form-control" name="password" />
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-lg-3 control-label">验证密码</label>
                                <div class="col-lg-5">
                                    <input type="password" class="form-control" name="confirmPassword" />
                                </div>
                            </div>
                      

                    

                        <div class="form-group">
                            <div class="col-lg-9 col-lg-offset-3">
                                <button type="submit" class="btn btn-primary">提交</button>
                            </div>
                        </div>
                    </form>
                </div>
            </section>
            <!-- :form -->
        </div>
    </div>

<script type="text/javascript">
$(document).ready(function() {
    $('#defaultForm').bootstrapValidator({
        message: 'This value is not valid',
        feedbackIcons: {
            valid: 'glyphicon glyphicon-ok',
            invalid: 'glyphicon glyphicon-remove',
            validating: 'glyphicon glyphicon-refresh'
        },
        fields: {
            username: {
                message: '用户名无效',
                validators: {
                    notEmpty: {
                        message: '用户名是必需的，不能为空'
                    },
                    stringLength: {
                        min: 6,
                        max: 30,
                        message: '用户名必须超过6个字符，长度不能超过30个字符'
                    },
                    regexp: {
                        regexp: /^[a-zA-Z0-9_\.]+$/,
                        message: '用户名只能由字母、数字、点和下划线组成'
                    }
                }
            },
            password: {
                validators: {
                    notEmpty: {
                        message: '需要密码，不能为空'
                    },
                    identical: {
                        field: 'confirmPassword',
                        message: '密码及其确认不一致'
                    }
                }
            },
            confirmPassword: {
                validators: {
                    notEmpty: {
                        message: '确认密码是必需的，不能为空'
                    },
                    identical: {
                        field: 'password',
                        message: '密码及其确认不一致'
                    }
                }
            }
        }
    });
});
</script>
</body>
</html>